package com.magicsoft.share.presenter.my;

import com.magicsoft.share.base.BasePresenter;
import com.magicsoft.share.bean.my.ArticleList;
import com.magicsoft.share.constant.APIService;
import com.magicsoft.share.constant.SPKey;
import com.magicsoft.share.rx_retrofit_network.location.retrofit.RetrofitUtil;
import com.magicsoft.share.rx_retrofit_network.location.rxandroid.LoadingTransformer;
import com.magicsoft.share.rx_retrofit_network.location.rxandroid.NetWorkTransformer;
import com.magicsoft.share.rx_retrofit_network.location.rxandroid.SimpleObserver;
import com.magicsoft.share.utils.SPUtils;
import com.magicsoft.share.view.my.IAllShareView;

/**
 * Created by lyf on 2017/11/22/022.
 */

public class AllSharePresenter extends BasePresenter<IAllShareView> {
    public void myArticleList(int pageNum, int pageSize, byte status) {
        RetrofitUtil.getApi(APIService.class).myArticleList(SPUtils.getInstance().getString(SPKey.TOKEN), SPUtils.getInstance().getLong(SPKey.ID),
                pageNum, pageSize, status)
                .compose(new NetWorkTransformer<ArticleList>())
                .compose(new LoadingTransformer<ArticleList>(mContext))
                .subscribe(new SimpleObserver<ArticleList>(mCompositeDisposable) {
                    @Override
                    public void call(ArticleList articleList) {
                        getView().myArticleListSuccess(articleList);
                    }

                    @Override
                    public void showErrorMsg(Throwable e, String errorMsg) {
                        super.showErrorMsg(e, errorMsg);
                        getView().myArticleListFail();
                    }
                });
    }
}
